package com.kmzx.one.project.config.listener;

import com.kmzx.one.project.events.PartnerViewEvent;
import com.kmzx.one.project.mapper.PartnerMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Project one
 * @Author: carol
 * @Date: 2020/5/29-14:23
 */
@Component(value = "partnerViewEventListener")
public class PartnerViewEventListener {

    private static Logger logger = LoggerFactory.getLogger(JRedisMessageListener.class);
    @Autowired
    PartnerMapper partnerMapper;

    @Async
    @EventListener(classes = {PartnerViewEvent.class})
//    @Transactional(rollbackFor = Exception.class)
    public void defaultPartnerViewEvent(PartnerViewEvent partnerViewEvent) throws Exception {
        logger.info("顶级 VIP 认证成功后,查看审核记录");
        String id = partnerViewEvent.getId();
        partnerMapper.updateViewedAuthHistory(id,new Date());
        logger.info("顶级 VIP 认证成功后,查看审核记录,OK");

    }
}
